<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateChatQuestionTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('chat_question', ['comment' => '猜你想问', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('room_id', 'string', ['limit' => 60, 'default' => 'admin', 'comment' => '房间号'])
            ->addColumn('title', 'string', ['limit' => 512, 'default' => '', 'comment' => '问题'])
            ->addColumn('content', 'text', ['null' => true, 'default' => null, 'comment' => '内容'])
            ->addColumn(Column::enum('status', ['normal', 'hidden'])->setDefault('normal')->setComment('状态'))
            ->addColumn('weigh', 'integer', ['limit'  =>  8, 'default' => 0, 'comment' => '权重'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addIndex('room_id')
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('chat_question');
        $table->drop();
    }
}
